package ioana.pack;

import java.util.ArrayList;
import java.util.Collections;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class OraseAdapter extends BaseAdapter
{
	private Activity context;
    ArrayList<String> orase;
    
    public OraseAdapter (Activity _context, ArrayList<String> _orase)
	{
		this.context = _context;
		orase = _orase; 
	}
	public int getCount()
	{
		// TODO Auto-generated method stub
		return orase.size();
		
	}
	

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return  0;
	}

	public View getView(int position, View convertView, ViewGroup list) {
				
		// TODO Auto-generated method stub
		TextView t;
		if (convertView==null)
		{
		LayoutInflater inflater = context.getLayoutInflater();
		convertView = inflater.inflate(R.layout.oras,null);
		t=(TextView) convertView.findViewById(R.id.oras);
		convertView.setTag(t);		
		}
		t=(TextView) convertView.getTag();
		t.setText(orase.get(position));
		return convertView;
	}
	public void adaugaOras(String oras)
	{
		orase.add(oras);
		Collections.sort (orase);
		notifyDataSetChanged();
	}
	public void stergeOras(int position)
	{
		orase.remove(position);
		notifyDataSetChanged();		
	}
	
}
